const request = require('../common/request')
const GetAccKey = require('../common/getAccessKey')

function getAuth(devices, time, valid) {
  return new Promise((reslove,reject) => {
    GetAccKey().then(key => {
      request({
        url: ' http://openapi.touchsprite.com/api/openapi',
        method: 'post',
        data: {
          action: 'getAuth',
          key,
          devices,
          time,
          valid
        }
      }).then(reslove).catch(reject)
    }).catch(reject)
  })
}

module.exports = getAuth